package com.jk.controller;

import com.jk.service.AuthOrgInfoService;
import com.jk.service.AuthRepInfoService;
import com.jk.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * Created by ${user} on ${data}.
 */
@RestController
@RequestMapping("AuthRepInfo")
public class AuthRepInfoController {
    @Autowired
    private AuthRepInfoService authRepInfoService;

    @GetMapping("SelectAuthRepInfo")
    public List<Map> SelectAuthOrgInfo(AuthRepInfo authRepInfo){
        List<Map> authRepInfoList = authRepInfoService.SelectAuthRepInfo(authRepInfo);
        return authRepInfoList;
    }

    @PutMapping("UpdateAuthRepInfo")
    public  int UpdateAuthRepInfo(AuthRepInfo authRepInfo, HttpSession request ,String userid){
        Employee employeelog = (Employee) request.getAttribute("employeelog");
        WorkOrder workOrder = new WorkOrder();
        if (employeelog!=null){
            workOrder.setWmployeeId(employeelog.getEmployeeId());
        }else{
            workOrder.setWmployeeId("1");
        }
        workOrder.setUserId(userid);
        System.out.println(workOrder.getWorkoderId());
       return authRepInfoService.UpdateAuthRepInfo(authRepInfo,workOrder);
    }
}
